package com.Tools.TestDb.Entity;

import com.baomidou.mybatisplus.annotation.TableName;

@TableName("interviewqas")
public class TestDb {
    private Long id;
    private String question;
    private String answer;
    private String questionType;
    private String bankType;
    private String source;
    private Integer difficulty;
    private Integer answerCount;
    private Integer averageScore;
    private String mastery;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getQuestion() {
        return question;
    }

    public void setQuestion(String question) {
        this.question = question;
    }

    public String getAnswer() {
        return answer;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

    public String getQuestionType() {
        return questionType;
    }

    public void setQuestionType(String questionType) {
        this.questionType = questionType;
    }

    public String getBankType() {
        return bankType;
    }

    public void setBankType(String bankType) {
        this.bankType = bankType;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public Integer getDifficulty() {
        return difficulty;
    }

    public void setDifficulty(Integer difficulty) {
        this.difficulty = difficulty;
    }

    public Integer getAnswerCount() {
        return answerCount;
    }

    public void setAnswerCount(Integer answerCount) {
        this.answerCount = answerCount;
    }

    public Integer getAverageScore() {
        return averageScore;
    }

    public void setAverageScore(Integer averageScore) {
        this.averageScore = averageScore;
    }

    public String getMastery() {
        return mastery;
    }

    public void setMastery(String mastery) {
        this.mastery = mastery;
    }
    // 更新题目得分、回答次数和掌握程度
    public void updateScore(int score) {
        this.answerCount++;
        this.averageScore = (this.averageScore * (this.answerCount - 1) + score) / this.answerCount;

        if (this.averageScore >= 8) {
            this.mastery = "熟练掌握";
        } else if (this.averageScore >= 5) {
            this.mastery = "掌握";
        } else {
            this.mastery = "未掌握";
        }
    }
    @Override
    public String toString() {
        return "TestDb{" +
                "id=" + id +
                ", question='" + question + '\'' +
                ", answer='" + answer + '\'' +
                ", questionType='" + questionType + '\'' +
                ", bankType='" + bankType + '\'' +
                ", source='" + source + '\'' +
                ", difficulty=" + difficulty +
                ", answerCount=" + answerCount +
                ", averageScore=" + averageScore +
                ", mastery='" + mastery + '\'' +
                '}';
    }
}
